package org.jeecg.modules.simulator.model.train.action;

import java.time.Duration;
import java.time.LocalTime;
import java.util.Date;

/**
 * @program: gp
 * @description:
 * @author: lydms
 * @create: 2024-08-08 10:10
 **/
public class TrainAction implements TrainActionRecorder {


    String id;
    String action;
    String affiliateType;
    LocalTime startTime;
    LocalTime endTime;
    Long during;
    Long planSpeed;
    Long actualSpeed;

    String actionName;
    String tableItemName;

    String tableItemId;
    Boolean send;
    Boolean finished;
    ExecutionStatus executionStatus;

    Boolean isLast;


    public TrainAction(String id, String action) {
        this.setId(id);
        this.setName(id);
        this.setAction(action);
        this.setFinished(false);
        this.setExecutionStatus(ExecutionStatus.initialize);
    }


    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    @Override
    public Boolean isFinished() {
        return this.finished;
    }

    @Override
    public void setFinished(Boolean finished) {
        this.finished = finished;
    }

    @Override
    public void setTableItemName(String name) {
        this.tableItemName = name;
    }

    @Override
    public String getTableItemName() {
        return this.tableItemName;
    }

    @Override
    public void setTableItemId(String id) {
        this.tableItemId = id;
    }

    @Override
    public String getTableItemId() {
        return this.tableItemId;
    }

    @Override
    public String getActionName() {
        return this.actionName;
    }

    @Override
    public Long getPlanSpeed() {
        return this.planSpeed;
    }

    @Override
    public void setPlanSpeed(long speed) {
        this.planSpeed = speed;
    }

    @Override
    public boolean isLast() {
        return isLast;
    }

    @Override
    public void setLast(boolean last) {
        isLast = last;
    }

    @Override
    public void setActualSpeed(long speed) {
        this.actualSpeed = speed;
    }

    @Override
    public Long getActualSpeed() {

        return this.actualSpeed;
    }


    @Override
    public String getName() {
        return this.actionName;
    }

    @Override
    public void setName(String name) {
        actionName = name;
    }

    @Override
    public String getAction() {
        return this.action;
    }

    @Override
    public void setAction(String action) {
        this.action = action;
    }

    @Override
    public String getAffiliateType() {
        return this.affiliateType;
    }

    @Override
    public void setAffiliateType(String affiliateType) {
        this.affiliateType = affiliateType;
    }

    @Override
    public LocalTime getStartTime() {
        return startTime;
    }

    @Override
    public void setStartTime(LocalTime startTime) {
        this.startTime = startTime;
    }

    @Override
    public LocalTime getEndTime() {
        return endTime;
    }

    @Override
    public void setEndTime(LocalTime endTime) {
        this.endTime = endTime;
    }


    @Override
    public Long getDuring() {
        Duration duration = Duration.between(startTime, endTime);
        return Math.abs(duration.getSeconds()); // 返回绝对值，避免负数
    }


    @Override
    public Boolean isSend() {
        return send;
    }

    @Override
    public void setSend(boolean send) {
        this.send = send;
    }

    @Override
    public ExecutionStatus getExecutionStatus() {
        return executionStatus;
    }

    @Override
    public void setExecutionStatus(ExecutionStatus executionStatus) {
        this.executionStatus = executionStatus;
    }

//    @Override
//    public int getLength() {
//        return 0;
//    }
}
